import store from '@/store';
import {
	mapState,
	mapMutations
} from 'vuex';
export default {
	data() {
		return {
			share_title: '',
			share_img: '',
			share_page: ''
		}
	},
	computed: {
		...mapState(['memberId', 'shareInfo'])
	},
	onLoad(options) {
		if (!!options.recommendId) {
			this.SET_INVITED(options.recommendId);
		}
	},
	methods: {
		...mapMutations(['SET_INVITED']),
	},
	onShareTimeline() {
		let scene = '';
		if (this.memberId) {
			scene = 'recommendId=' + this.memberId;
		}
		let shareParams = {
			title: this.share_title || this.shareInfo.title || `欢迎来到${this.appName}`,
			imageUrl: this.share_img,
			path: this.share_page || `/pages/splash/splash`,
			query: scene
		};
		console.log('shareParams', shareParams)
		return shareParams;
	},
	onShareAppMessage() {
		let scene = '';
		if (this.memberId) {
			scene = 'recommendId=' + this.memberId;
		}
		let shareParams = {
			title: this.share_title || this.shareInfo.title || `欢迎来到${this.appName}`,
			imageUrl: this.share_img,
			path: (this.share_page || '/pages/splash/splash') + '?' + scene
		};
		console.log('shareParams', shareParams)
		return shareParams;
	},

}
